#include<stdio.h>
#include<stdlib.h>

#define Max 100
struct sqlist
{
	int data[Max];
	int length;
};

void InsertElementToSqlist(struct sqlist *l,int n,int x)
{
	int j;
	if(n<0||n>l->length)
	{
		printf("位置错误!\n");
		return;
	}
	else if(l->length>Max)
	{
		printf("溢出！\n");
	}
	for(j=l->length-1;j>=n;j--)
		l->data[j+1]=l->data[j];
	l->data[n]=x;
	l->length++;
}

int main()
{
	struct sqlist *l;
	int n,i,data;
	l=(struct sqlist*)malloc(sizeof(struct sqlist));
	l->length=0;
	printf("请输入顺序表的长度:\n");
	scanf("%d",&n);
	printf("请输入循序表的元素:\n");
	for(i=0;i<n;i++)
	{
		scanf("%d",&data);
		InsertElementToSqlist(l,i,data);
	}
	printf("当前循序表是:\n");
	for(i=0;i<l->length;i++)
	{
		printf("%d ",l->data[i]);
	}
	
	return 0;
}


